<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul id="u">
        <li id="1">1</li>
        <li class="other">2</li>
        <li class="other">3</li>
    </ul>
    <button class="btn">追加按钮</button>
    <script>
        const liAll = document.querySelectorAll("li")
        const lis = document.getElementsByTagName("li")
        const btn = document.getElementsByClassName("btn")
        const uls = document.getElementById("u")

        btn[0].onclick = function () {
            for (let i = 0; i < liAll.length; i++) {
                const newLi = document.createElement("li")
                newLi.innerHTML = `${lis.length}`
                uls.appendChild(newLi)
            }
            const newLiAll = document.getElementsByTagName("li")
            console.log(newLiAll)
        }

    </script>
</body>
</html>